import request from '@/axios';

export const oss = {
  putFile: '/api/civil-resource/oss/endpoint/put-file'
};

/**
 * 创建存储桶
 * @param params
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export const makeBucket = (params) => {
  return request({
    url: '/api/oss/endpoint/make-bucket',
    method: 'post',
    params: {
      ...params
    }
  });
};

/**
 * 删除存储桶
 * @param params
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export const removeBucket = (params) => {
  return request({
    url: '/api/oss/endpoint/remove-bucket',
    method: 'post',
    params: {
      ...params
    }
  });
};

export const initTask = (params) => {
  return request({
    url: '/api/civil-resource/oss/endpoint',
    method: 'post',
    data: params
  });
};
export const merge = (identifier) => {
  return request({
    url: `/api/civil-resource/oss/endpoint/merge/${identifier}`,
    method: 'post'
  });
};
export const preSignUrl = ({ identifier, partNumber }) => {
  return request({
    url: `/api/civil-resource/oss/endpoint/${identifier}/${partNumber}`,
    method: 'get'
  });
};
export const selectTask = () => {
  return request({
    url: '/api/civil-resource/oss/endpoint/minioList',
    method: 'get'
  });
};
export const taskInfo = (identifier) => {
  return request({
    url: `/api/civil-resource/oss/endpoint/${identifier}`,
    method: 'get'
  });
};
